package org.jeecgframework.boot.springaimcpservice.config;

import jakarta.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Resource
    private  DoSoftConfig doSoftConfig;
    
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 配置外部目录（绝对路径）
        registry.addResourceHandler("/file/**")
                .addResourceLocations("file:"+doSoftConfig.getUploadPath()+"/");

        // 配置类路径下的目录
        registry.addResourceHandler("/custom/**")
                .addResourceLocations("classpath:/custom-static/");

        // 保留默认配置（可选）
        WebMvcConfigurer.super.addResourceHandlers(registry);
    }
    
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        // 添加视图控制器
        registry.addViewController("/").setViewName("stats-query-test");
        registry.addViewController("/test").setViewName("stats-query-test");
    }
}